#include <stdio.h>
int main()
{int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
 int year;
 int month;
 int day;
 int sum;
 int i;
 scanf("%d",&year);
 scanf("%d",&month);
 scanf("%d",&day);
 if(year%400==0||year%4==0&&year%100!=0)
 {  a[0]=day;
        a[2]=29;}
 else
 {  a[0]=day;
        a[2]=28;}
for(i=0;i<month;i++)
    sum=sum+a[i];
printf("%d",sum);
}